############# ########### ####### ##### ### ##
#
# Copyright (C) 2010 The Hursk Group, LLC
#
# This program is free software: you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (See file named COPYING).  If not, see 
# <http://www.gnu.org/licenses/>.
# 
############# ########### ####### ##### ### ##

#!/bin/sh
#
#
#
#*******************************************
# TCP_SYN_PING_PORT is a list of ports to be used for the ping scan (enumeration only) uncomment the one you want.
TCP_SYN_PING_PORT_LIST=1,2,3,4,5,7,11,19,20,21,22,23,25,53,79,80,81,98,109,110,111,119,123,137,138,139,143,161,389,427,443,445,512,513,514,515,524,548,631,635,636,1011,1015,1016,1035,1080,1433,1434,1521,1812,1984,2000,3031,3181,3268,3283,3306,3689,5222,5223,5297,5298,5432,3128,3389,4000,4750,5000,5631,5632,5800,5801,5900,6000,6129,6346,6665,6666,6667,6668,6669,8080,8081,8082,8770,10000,10319,12345,12346,16372,16660,20034,27374,27444,27665,31335,31337,31789,31790,32771,32773,43189,43190,54320,54321,65000,65301
#TCP_SYN_PING_PORT_LIST=21,22,25,80,443,135,139,445,8080,3128 

#*******************************************
# Which ports to look at for full scanning. Uncomment the one you want.
#SCAN_PORTS=1,100,1000,10000,10005,1002,1008,10080,10082,10083,101,1012,102,1023,1024,1025,1026,1027,1028,1029,103,1030,1031,1032,1033,104,1040,105,1050,1058,1059,106,1067,1068,107,1076,108,1080,1083,1084,109,11,110,1103,1109,111,1110,1112,112,1127,113,11371,1139,114,115,1155,116,1167,117,1178,118,119,120,12000,121,1212,1214,122,1220,1222,123,1234,12345,12346,124,1241,1248,125,126,127,128,129,13,130,131,132,133,1337,134,1346,1347,1348,1349,135,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,136,1360,1361,1362,1363,1364,1365,1366,1367,1368,1369,137,1370,13701,13702,13705,13706,13708,13709,1371,13710,13711,13712,13713,13714,13715,13716,13717,13718,1372,13720,13721,13722,1373,1374,1375,1376,1377,1378,13782,13783,1379,138,1380,1381,1383,1384,1385,1386,1387,1388,1389,139,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,140,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,141,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,142,1420,1421,1422,1423,1424,1425,1426,1427,1428,1429,143,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,144,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,145,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,146,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,147,1470,1471,1472,1473,1474,1475,1476,1477,1478,1479,148,1480,1481,1482,1483,1484,1485,1486,1487,1488,1489,149,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,15,150,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,151,1510,1511,1512,15126,1513,1514,1515,1516,1517,1518,1519,152,1520,1521,1522,1523,1524,1525,1526,1527,1528,1529,153,1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,154,1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,155,1550,1551,1552,156,157,158,159,160,1600,161,162,163,164,1645,1646,165,1650,1651,1652,166,1661,1662,1663,1664,1665,1666,1667,1668,1669,167,1670,1671,1672,168,1680,169,16959,17,170,17007,1701,171,17185,172,1720,1723,173,17300,174,175,1755,176,1761,1762,1763,1764,177,178,179,18,180,18000,181,1812,1813,18181,18182,18183,18184,18185,18187,182,1827,183,184,185,186,187,188,189,19,190,1900,191,19150,192,193,1935,194,195,196,197,198,1984,1986,1987,1988,1989,199,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2,20,200,2000,20005,2001,2002,2003,2004,2005,2006,2007,2008,2009,201,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,202,2020,2021,2022,2023,2024,2025,2026,2027,2028,203,2030,2032,2033,2034,2035,2038,204,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,205,2053,206,2064,2065,2067,2068,207,208,209,21,210,2103,2104,2105,2106,2108,211,2111,2112,212,2120,2121,213,214,215,216,217,218,219,22,220,2201,221,222,22273,22289,223,22305,2232,22321,22370,2241,23,2301,2307,24,2401,242,243,2430,2431,2432,2433,244,245,246,247,248,25,2500,2501,256,2564,257,258,259,260,2600,26000,2601,2602,2603,2604,2605,261,262,26208,2627,2628,263,2638,264,265,26900,27,27000,27001,27002,27003,27004,27005,27006,27007,27008,27009,27010,27015,27374,27444,27500,2766,27665,2784,27910,27960,280,2809,281,282,28910,29,2903,2967,2998,3,3000,3001,3005,3006,3049,3052,3064,308,3086,309,31,310,311,312,3128,313,3130,31335,31337,314,3141,315,316,317,321,3264,3268,3269,32768,32770,32771,32772,32773,32774,32775,32776,32777,32778,32779,32780,32786,32787,3292,33,3306,3333,3372,3389,3401,3421,344,345,3455,3456,3457,346,3462,347,348,349,35,350,351,352,353,3531,354,355,356,357,358,359,360,361,362,363,3632,364,365,366,367,368,3689,369,37,370,371,372,373,374,375,376,377,378,379,38,380,38037,381,382,38292,38293,383,384,385,386,387,388,389,39,390,3900,391,392,39213,393,394,395,396,397,398,3984,3985,3986,399,3996,3997,3998,3999,400,4000,4008,401,402,403,404,4045,405,406,407,408,409,41,410,411,412,413,4132,4133,414,4144,415,416,417,418,419,42,420,421,422,4224,423,424,425,426,427,428,429,43,430,431,43188,432,4321,433,4333,434,4343,435,436,437,438,439,44,440,441,442,443,44334,444,4444,44442,44443,445,446,447,448,4480,449,45,450,4500,45000,451,452,453,454,455,4557,4559,456,457,458,459,46,460,461,462,463,464,465,466,4660,467,4672,468,469,47,470,471,472,473,474,475,47557,476,477,478,479,48,480,481,482,4827,483,484,485,486,487,488,489,4899,49,490,491,492,493,494,49400,495,496,497,498,4987,499,4998,5,50,500,5000,5001,5002,5003,501,5010,5011,502,503,504,505,5050,506,507,508,509,51,510,5100,5101,5102,511,512,513,514,5145,515,516,517,518,519,5190,5191,5192,5193,52,520,521,522,523,5232,5236,524,525,526,527,528,529,53,530,5300,5301,5302,5303,5304,5305,5308,531,532,533,534,535,536,537,538,539,54,540,5400,5405,541,542,5428,543,5432,54320,54321,544,545,546,547,548,549,5490,55,550,5500,551,5510,552,5520,553,5530,554,5540,555,55
SCAN_PORTS=1-65535

#*******************************************
# Is this a discovery scan or a -sS scan (full)
DISCO=0 # 1 makes this a discovery scan using -sP against the ports found in TCP_SN_PING_PORT_LIST, 0 makes it a -sS scan

#*******************************************
# host specification
TARGET_HOSTS=10.0.0.0/16

#*******************************************
# Timing template T0-5.
TIMEING=T4

#*******************************************
# Output file name
OUTPUT=scan_output

if [ "$DISCO" -eq 1 ]; then
	sudo nmap -sP -vv -${TIMEING} -PS${COMMONPORTS} ${TARGET_HOSTS} -oX ${OUTPUT}.xml -oN ${OUTPUT}.gn 2>&1 >> ${OUTPUT}.out
else
	sudo nmap -P0 -vv -sS -${TIMEING} -p ${SCAN_PORTS} ${TARGET_HOSTS} -oX ${OUTPUT}.xml -oN ${OUTPUT}.gn 2>&1 >> ${OUTPUT}.out
fi






